﻿using Microsoft.EntityFrameworkCore;
using Abp.Zero.EntityFrameworkCore;
using SOEI.Solution.Authorization.Roles;
using SOEI.Solution.Authorization.Users;
using SOEI.Solution.MultiTenancy;
using SOEI.Solution.EntityFrameworkCore.EntityMapper;
using System.Linq;
using E;
using SOEI.Solution.Integratedes.Organization;
using SOEI.Solution.Integratedes.ElectronicSignet;
using SOEI.Solution.DomainEntities.Organization;
using SOEI.Solution.EntityMapper;
using SOEI.Solution.DomainEntities.CustomerManagement;
using SOEI.Solution.DomainEntities.RoomSourceVerifiy;
using SOEI.Solution.DomainEntities.RoomSourceVerifiyV1;
using SOEI.Solution.DomainEntities.BuyQualification;
using SOEI.Solution.CommonOthers;
using SOEI.Solution.CommonOthers.Pdf;
using SOEI.Solution.FileUpLoader;
using System.Reflection.Metadata;
using SOEI.Solution.DomainEntities.Parameters;
using Parameter = SOEI.Solution.DomainEntities.Parameters.Parameter;

namespace SOEI.Solution.EntityFrameworkCore
{
    /// <summary>
    /// 【SolutionDbContext扩展】系统扩展时候新建的 DbSet
    /// </summary>
    public partial class SolutionDbContext
    {
        #region ======================================== 经济机构 
        /// <summary>
        /// 经济机构表
        /// </summary>
        public virtual DbSet<EconomyOrgani> EconomyOrganies { get; set; }
        /// <summary>
        /// 【新表功能结构】机构电子签章
        /// </summary>
        public virtual DbSet<OrgSignet> OrgSignets { get; set; }

        /// <summary>
        /// 【新表功能结构】印章授权表
        /// </summary>
        public virtual DbSet<SignetGrant> SignetGrants { get; set; }

        /// <summary>
        /// 【新表功能结构】承诺书表
        /// </summary>
        public virtual DbSet<PledgeBook> PledgeBooks { get; set; }

        #endregion

        #region ======================================== 客源管理相关

        /// <summary>
        /// 客源管理-买方信息数据表
        /// </summary>
        public virtual DbSet<Buyer> Buyers { get; set; }

        /// <summary>
        /// 客源管理-卖方信息数据表
        /// </summary>
        public virtual DbSet<Seller> Sellers { get; set; }

        #endregion

        #region ======================================== 房源核验
        /// <summary>
        /// 房源核验表
        /// </summary>
        public virtual DbSet<RoomVerify> RoomVerifys { get; set; }

        /// <summary>
        /// 房源核验申请表
        /// </summary>
        public virtual DbSet<RoomVerifyApply> RoomVerifyApplys { get; set; }

        public virtual DbSet<RoomVerifyProperty> RoomVerifyPropertys { get; set; }


        #endregion

        #region ======================================== 购资审核

        /// <summary>
        /// 购买资格信息表
        /// </summary>
        public virtual DbSet<BuyQualification> BuyQualifications { get; set; }
        /// <summary>
        /// 购资审核申请表
        /// </summary>
        public virtual DbSet<BuyQualificationApply> BuyQualificationApplys { get; set; }

        #endregion

        #region ======================================== 其他类型

        public virtual DbSet<Default> Defaults { get; set; }

        /// <summary>
        /// PDF内容
        /// </summary>
        public virtual DbSet<PDFContent> PDFContents { get; set; }

        /// <summary>
        /// 文件上传实体（新系统）
        /// </summary>
        public virtual DbSet<Attach> Attachs { get; set; }

        /// <summary>
        /// 公用参数
        /// </summary>
        public virtual DbSet<Parameter> Parameters { get; set; }
        
        #endregion


        /// <summary>
        ///  配置用户表
        /// </summary>
        /// <param name="modelBuilder"></param>
        protected void SetNewUserTablePrefix(ModelBuilder modelBuilder)
        {
            #region 经济机构相关
            modelBuilder.ApplyConfiguration(new EconomyOrganiMapper()); // 机构签章表
            modelBuilder.ApplyConfiguration(new OrgSignetMapper()); // 机构签章表
            modelBuilder.ApplyConfiguration(new SignetGrantMapper());  // 请将代码配置到这里 
            modelBuilder.ApplyConfiguration(new PledgeBookMapper());

            #endregion

            #region 客源管理相关

            modelBuilder.ApplyConfiguration(new BuyerMapper());
            modelBuilder.ApplyConfiguration(new SellerMapper());

            #endregion

            #region 房源核验

            modelBuilder.ApplyConfiguration(new RoomVerifyMapper());
            modelBuilder.ApplyConfiguration(new RoomVerifyApplyMapper());
            modelBuilder.ApplyConfiguration(new RoomVerifyPropertyMapper());

            #endregion

            #region 购资审核

            modelBuilder.ApplyConfiguration(new BuyQualificationMapper());
            modelBuilder.ApplyConfiguration(new BuyQualificationApplyMapper());

            #endregion

            #region 其他类型
            //Default
            modelBuilder.ApplyConfiguration(new DefaultMapper());
            modelBuilder.ApplyConfiguration(new PDFContentMapper());
            modelBuilder.ApplyConfiguration(new AttachMapper());
            modelBuilder.ApplyConfiguration(new ParameterMapper());// 这是一个查询

            #endregion

        }


    }
}
